Repository navigation
audio: add dynamic playback and capture route selection - #613
Srikanth Muppandam (smuppand) wants to merge 5 commits into
Conversation
Signed-off-by: Srikanth Muppandam <smuppand@qti.qualcomm.com>
Signed-off-by: Srikanth Muppandam <smuppand@qti.qualcomm.com>
Signed-off-by: Srikanth Muppandam <smuppand@qti.qualcomm.com>
Signed-off-by: Srikanth Muppandam <smuppand@qti.qualcomm.com>
Signed-off-by: Srikanth Muppandam <smuppand@qti.qualcomm.com>
| chunk_id = chunk_header[0:4] | ||
| chunk_size = struct.unpack_from("<I", chunk_header, 4)[0] | ||
| next_offset = offset + 8 + chunk_size + (chunk_size & 1) | ||
| if next_offset > file_bytes: |
There was a problem hiding this comment.
The important calculation is: next_offset = offset + 8 + chunk_size + (chunk_size & 1)
where:
- 8 = 4-byte chunk ID + 4-byte size
- chunk_size = payload length
- chunk_size & 1 = 1 when payload length is odd, otherwise 0
One robustness improvement
Because _read_exact() may raise an exception if the file is unexpectedly truncated or changes after file_bytes was obtained, you could defensively handle that case:
try:
chunk_header = _read_exact(handle, 8)
except (EOFError, OSError):
return False, tuple(chunk_names)
There was a problem hiding this comment.
Thanks for checking the chunk alignment. Yes, the calculation includes the 8-byte header and the padding byte for an odd-sized payload.
For the truncation case, _read_exact() raises WavValidationError, not EOFError. That exception, along with OSError from reading or seeking, already propagates through parse_wave() to the CLI exception handler, which emits a structured ERROR and returns exit code 2 rather than an unhandled traceback.
I would retain that propagation here. Returning False instead would classify the problem as an unrecognized trailing-chunk layout, which the caller treats as a warning, potentially allowing validation to pass despite an I/O failure. Also, the proposed except (EOFError, OSError) would not catch this helper's short-read exception. No additional catch is needed for the reported CLI failure path.
Add runtime audio-route discovery without hard-coded card, PCM, sink, or source names.
Changes
speaker,headset,mic, andheadset-micoverrides.Result handling
Fixes #454